﻿//////////////////////////////////////////////////////////////////////////////
//
// Copyright © 1998-2024 Glodon Company Limited.
//
// Licensed under the MIT License
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the “Software”),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
//////////////////////////////////////////////////////////////////////////////
#pragma once

#include "ui_RevisionCloudStyleDlg.h"
#include "GbmpNew.h"
namespace gcmp
{
    class IDocument;
    class ElementId;
    class IRevisionCloud;
}
class DetailStyleWidget : public QWidget
{
public:
    DetailStyleWidget(QWidget* parent) :QWidget(parent)
    {
        setupUi();
    }
    ~DetailStyleWidget()
    {

    }
    void setupUi()
    {
        this->resize(400, 200);

        QSizePolicy sizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
        sizePolicy.setHorizontalStretch(0);
        sizePolicy.setVerticalStretch(0);
        //sizePolicy.setHeightForWidth(this->sizePolicy().hasHeightForWidth());
        this->setSizePolicy(sizePolicy);
        this->setMinimumSize(QSize(0, 0));
        this->setMaximumSize(QSize(16777215, 500));

        //gridLayout = NEW_AS_QT(QGridLayout(this);
        groupBox_1 = NEW_AS_QT(QGroupBox,this);
        //this = NEW_AS_QT(Qthis(this);
        groupBox_1->setObjectName(QStringLiteral("groupBox"));
        verticalLayout = NEW_AS_QT(QVBoxLayout,groupBox_1);
        verticalLayout->setSpacing(6);
        verticalLayout->setContentsMargins(11, 11, 11, 11);
        verticalLayout->setObjectName(QStringLiteral("verticalLayout"));
        label_2 = NEW_AS_QT(QLabel,groupBox_1);
        label_2->setObjectName(QStringLiteral("label_2"));

        verticalLayout->addWidget(label_2);

        horizontalLayout = NEW_AS_QT(QHBoxLayout);
        horizontalLayout->setSpacing(6);
        horizontalLayout->setObjectName(QStringLiteral("horizontalLayout"));
        label = NEW_AS_QT(QLabel,groupBox_1);
        label->setObjectName(QStringLiteral("label"));

        horizontalLayout->addWidget(label);

        lineEditLoop = NEW_AS_QT(QLineEdit,groupBox_1);
        lineEditLoop->setObjectName(QStringLiteral("lineEditLoop_1"));
        lineEditLoop->setReadOnly(true);

        horizontalLayout->addWidget(lineEditLoop);

        verticalLayout->addLayout(horizontalLayout);

        label_3 = NEW_AS_QT(QLabel,groupBox_1);
        label_3->setObjectName(QStringLiteral("label_3"));

        verticalLayout->addWidget(label_3);

        horizontalLayout_2 = NEW_AS_QT(QHBoxLayout);
        horizontalLayout_2->setSpacing(6);
        horizontalLayout_2->setObjectName(QStringLiteral("horizontalLayout_2"));
        label_4 = NEW_AS_QT(QLabel,this);
        label_4->setObjectName(QStringLiteral("label_4"));

        horizontalLayout_2->addWidget(label_4);

        lineEditAnnatation = NEW_AS_QT(QLineEdit,groupBox_1);
        lineEditAnnatation->setObjectName(QStringLiteral("lineEditAnnatation_1"));

        horizontalLayout_2->addWidget(lineEditAnnatation);


        verticalLayout->addLayout(horizontalLayout_2);

        label_6 = NEW_AS_QT(QLabel,groupBox_1);
        label_6->setObjectName(QStringLiteral("label_6"));

        verticalLayout->addWidget(label_6);

        horizontalLayout_3 = NEW_AS_QT(QHBoxLayout);
        horizontalLayout_3->setSpacing(6);
        horizontalLayout_3->setObjectName(QStringLiteral("horizontalLayout_3"));
        label_5 = NEW_AS_QT(QLabel,groupBox_1);
        label_5->setObjectName(QStringLiteral("label_5"));

        horizontalLayout_3->addWidget(label_5);

        lineEditVersion = NEW_AS_QT(QLineEdit,groupBox_1);
        lineEditVersion->setObjectName(QStringLiteral("lineEditVersion_1"));

        horizontalLayout_3->addWidget(lineEditVersion);


        verticalLayout->addLayout(horizontalLayout_3);

        label_7 = NEW_AS_QT(QLabel,groupBox_1);
        label_7->setObjectName(QStringLiteral("label_7"));

        verticalLayout->addWidget(label_7);

        horizontalLayout_4 = NEW_AS_QT(QHBoxLayout);
        horizontalLayout_4->setSpacing(6);
        horizontalLayout_4->setObjectName(QStringLiteral("horizontalLayout_4"));
        label_8 = NEW_AS_QT(QLabel,groupBox_1);
        label_8->setObjectName(QStringLiteral("label_8"));

        horizontalLayout_4->addWidget(label_8);

        lineEditLinewire = NEW_AS_QT(QLineEdit,groupBox_1);
        lineEditLinewire->setObjectName(QStringLiteral("lineEditLinewire_1"));
        lineEditLinewire->setReadOnly(true);

        horizontalLayout_4->addWidget(lineEditLinewire);


        verticalLayout->addLayout(horizontalLayout_4);


        retranslateUi();

    } // setupUi

    void retranslateUi()
    {
        groupBox_1->setTitle(QString::fromStdWString(GBMP_TR(L"样式详细")));
        label_2->setText(QString::fromStdWString(GBMP_TR(L"云线样式")));
        label->setText(QString::fromStdWString(GBMP_TR(L"线样式")));
        label_3->setText(QString::fromStdWString(GBMP_TR(L"注释版本样式")));
        label_4->setText(QString::fromStdWString(GBMP_TR(L"文字样式")));
        label_6->setText(QString::fromStdWString(GBMP_TR(L"版本样式")));
        label_5->setText(QString::fromStdWString(GBMP_TR(L"文字样式")));
        label_7->setText(QString::fromStdWString(GBMP_TR(L"引线样式")));
        label_8->setText(QString::fromStdWString(GBMP_TR(L"线样式")));

    } // retranslateUi
public:
    QLineEdit* lineEditLoop;
    QLineEdit* lineEditAnnatation;
    QLineEdit* lineEditVersion;
    QLineEdit* lineEditLinewire;
private:
    QGroupBox* groupBox_1;
    QVBoxLayout* verticalLayout;
    QLabel* label_2;
    QHBoxLayout* horizontalLayout;
    QLabel* label;
    QLabel* label_3;
    QHBoxLayout* horizontalLayout_2;
    QLabel* label_4;
    QLabel* label_6;
    QHBoxLayout* horizontalLayout_3;
    QLabel* label_5;
    QLabel* label_7;
    QHBoxLayout* horizontalLayout_4;
    QLabel* label_8;
};
class DetailStyleDialog : public QDialog
{
    Q_OBJECT
public:
    DetailStyleDialog(QWidget* parent = 0) 
    {
        setupUI();
        connect(pushButtonOK, SIGNAL(clicked()), this, SLOT(accept()));
        connect(pushButtonCancal, SIGNAL(clicked()), this, SLOT(reject()));
    }
    ~DetailStyleDialog() {}
public:
    void setValue(const QString& strStyleLoop, const QString& strStyleAnnatation,
        const QString& strStyleVersion, const QString& strStyleLinewire)
    {
        detailStyleWidget->lineEditLoop->setText(strStyleLoop);
        detailStyleWidget->lineEditAnnatation->setText(strStyleAnnatation);
        detailStyleWidget->lineEditVersion->setText(strStyleVersion);
        detailStyleWidget->lineEditLinewire->setText(strStyleLinewire);

    }
    void GetValue(QString& strStyleLoop, QString& strStyleAnnatation,
        QString& strStyleVersion, QString& strStyleLinewire)
    {
        strStyleLoop = detailStyleWidget->lineEditLoop->text();
        strStyleAnnatation = detailStyleWidget->lineEditAnnatation->text();
        strStyleVersion = detailStyleWidget->lineEditVersion->text();
        strStyleLinewire = detailStyleWidget->lineEditLinewire->text();
    }
private:
    void setupUI()
    {
        this->resize(250, 300);

        QSizePolicy sizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
        sizePolicy.setHorizontalStretch(0);
        sizePolicy.setVerticalStretch(0);
        this->setSizePolicy(sizePolicy);
        this->setMinimumSize(QSize(0, 0));
        this->setMaximumSize(QSize(16777215, 16777215));
        
        QVBoxLayout *verticalLayout = NEW_AS_QT(QVBoxLayout,this);
        verticalLayout->setSpacing(6);
        verticalLayout->setContentsMargins(11, 11, 11, 11);
        verticalLayout->setObjectName(QStringLiteral("verticalLayout"));

        detailStyleWidget = NEW_AS_QT(DetailStyleWidget,this);
        verticalLayout->addWidget(detailStyleWidget);

        QHBoxLayout *horizontalLayout = NEW_AS_QT(QHBoxLayout);
        horizontalLayout->setSpacing(6);
        horizontalLayout->setObjectName(QStringLiteral("horizontalLayout"));

        pushButtonOK = NEW_AS_QT(QPushButton,this);
        pushButtonOK->setText(QStringLiteral("OK"));
        pushButtonOK->setObjectName(QStringLiteral("OK"));
        horizontalLayout->addWidget(pushButtonOK);

        pushButtonCancal = NEW_AS_QT(QPushButton,this);
        pushButtonCancal->setText(QStringLiteral("Cancel"));
        pushButtonCancal->setObjectName(QStringLiteral("Cancel"));
        horizontalLayout->addWidget(pushButtonCancal);
        
        verticalLayout->addLayout(horizontalLayout);
    }
private:
    DetailStyleWidget* detailStyleWidget;
    QPushButton* pushButtonOK;
    QPushButton* pushButtonCancal;
};
class RevisionCloudStyleDlg :public QDialog
{
    Q_OBJECT
public:
    RevisionCloudStyleDlg(gcmp::IDocument*pDoc, const gcmp::ElementId& revCloudId, QWidget *parent = 0);
    ~RevisionCloudStyleDlg();

    private slots:
    void onMoveRequested(const QPoint& cursorPos, const QPoint& offset);
    void ClickOkButton();
    void ClickCancelButton();
    void ClickOkButtonSelect();
    void ClickCancelButtonSelect();
    void onTypeChanged(const QString& strText);

    void onChangeTypeOfSelectedElement(const QString& strText);
    void OnComponentTypeAddButtonClick();
private:
    void InitStyles();
    void InitSetElementType(gcmp::IDocument* pDoc);

    gcmp::IRevisionCloud* GetSelectedElement(gcmp::IDocument*pDoc);


    gcmp::IDocument* m_pDocument;
    Ui::RevCloudStyleDlg m_ui;
};
